<template>
	<!-- <div v-cloak class="aui-wrapper aui-page__iframe">
        <div class="aui-content__wrapper">
            <div class="aui-content">
                <el-card shadow="never" class="aui-card--fill">
                    <div class="mod-lswms__putawaystrategydetail"> -->
	<el-dialog v-model="visible" title="明细 " :close-on-click-modal='false' :close-on-press-escape='false'
		:fullscreen='true'>
		<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
			<!-- <el-form-item>
				<el-input v-model="dataForm.id" placeholder="id" clearable></el-input>
			</el-form-item> -->
			<el-form-item>
				<el-button size="small" @click="getDataList()">刷新</el-button>
			</el-form-item>
			<el-form-item>
				<el-button type="primary"
					@click="addOrUpdaputawaystrategydetailHandle( dataForm.id,dataForm.strategykey)"  size="small"
						   v-if="hasPermission('lswms:putawaystrategy:save')" >新增</el-button>
			</el-form-item>
			<el-form-item>
				<el-button type="danger" @click="deleteHandle()" size="small"
						   v-if="hasPermission('lswms:putawaystrategy:delete')" >删除</el-button>
			</el-form-item>
		<!-- 	<el-form-item>
				<el-button type="info" @click="exportHandle()">导出</el-button>
			</el-form-item> -->
		</el-form>
		<el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle"
			@sort-change="dataListSortChangeHandle" style="width: 100%;">
			<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
			<!-- <el-table-column prop="id" label="序号"  header-align="center"  align="center"></el-table-column> -->
			<el-table-column prop="strategykey" label="上架策略号" header-align="center" align="center"></el-table-column>
			<el-table-column prop="linenum" label="明细号" header-align="center" align="center"></el-table-column>
			<el-table-column prop="orderline" label="顺序号" header-align="center" align="center"></el-table-column>
			<el-table-column prop="strategycodestr" label="上架策略码" header-align="center" align="center"> 
			</el-table-column>
			<el-table-column prop="fromzonecodestr" label="自区" header-align="center" align="center">
			</el-table-column>
			<el-table-column prop="tozonecodestr" label="至区" header-align="center" align="center">
			</el-table-column>
			<el-table-column prop="fromloc" label="自库位" header-align="center" align="center"></el-table-column>
			<el-table-column prop="toloc" label="至库位" header-align="center" align="center"></el-table-column>
			<el-table-column prop="loctypestr" label="库位类型" header-align="center" align="center">
			</el-table-column>
			<el-table-column prop="loccategorystr" label="库位类别" header-align="center" align="center">
			</el-table-column>
			<el-table-column prop="locstatusstr" label="库位状态" header-align="center" align="center">
			</el-table-column>
			<el-table-column prop="lane" label="巷道" header-align="center" align="center"></el-table-column>
			<el-table-column prop="laneSide" label="巷道侧边" header-align="center" align="center"></el-table-column>
			<el-table-column prop="laneDepth" label="巷道侧边的深度" header-align="center" align="center"></el-table-column>
			<el-table-column prop="traytype" label="箱类型" header-align="center" align="center">
			</el-table-column>
			<el-table-column prop="skusortstr" label="物料分类" header-align="center" align="center">
			</el-table-column>
			<el-table-column prop="rowcollevorderstr" label="排列层顺序" header-align="center" align="center">
			</el-table-column>
			<el-table-column prop="roworderstr" label="排顺序" header-align="center" align="center">
			</el-table-column>
			<el-table-column prop="columnorderstr" label="列顺序" header-align="center" align="center">
			</el-table-column>
			<el-table-column prop="levelorderstr" label="层顺序" header-align="center" align="center">
			</el-table-column>
			<el-table-column prop="reserve1" label="备用字段1" header-align="center" align="center"></el-table-column>
			<el-table-column prop="reserve2" label="备用字段2" header-align="center" align="center"></el-table-column>
			<!-- <el-table-column prop="reserve3" label="备用字段3" header-align="center" align="center"></el-table-column>
			<el-table-column prop="reserve4" label="备用字段4" header-align="center" align="center"></el-table-column>
			<el-table-column prop="reserve5" label="备用字段5" header-align="center" align="center"></el-table-column>
			<el-table-column prop="adduser" label="创建人" header-align="center" align="center"></el-table-column>
			<el-table-column prop="addtime" label="创建时间" header-align="center" align="center"></el-table-column>
			<el-table-column prop="updatuser" label="更新人" header-align="center" align="center"></el-table-column>
			<el-table-column prop="updatetime" label="更新时间" header-align="center" align="center"></el-table-column> -->
			<el-table-column label='操作' fixed="right" header-align="center" align="center" width="150">
				<template #default="scope">
					<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)"  v-if="hasPermission('lswms:putawaystrategy:update')" >修改</el-button>
					<el-button type="text" size="small" @click="deleteHandle(scope.row.id)" v-if="hasPermission('lswms:putawaystrategy:delete')" >删除</el-button>
				</template>
			</el-table-column>
		</el-table>
		<el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
			layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
			@current-change="pageCurrentChangeHandle">
		</el-pagination>
		<!-- 弹窗, 新增 / 修改 -->
		<putawaystrategydetailAddOrUpdate v-if="addOrUpdateVisible" ref="addOrUpdate" @refresh-data-list="getDataList">
		</putawaystrategydetailAddOrUpdate>
	</el-dialog>
	<!-- </div>
                </el-card>
            </div>
        </div>
    </div> -->
</template>

<script>
	import DataList from "@/utils/DataList";
	import {
		ref,
		reactive,
		onMounted,
		nextTick
	} from 'vue';
	import putawaystrategydetailAddOrUpdate from "@/components/lswms/base/PutawaystrategydetailAddOrUpdate";
	import {
		getzonelist
	} from "@/network/lswms/base/Zone.js"
	import {
		getCodeListByCode
	} from "@/network/lswms/base/Codelist.js"
	import {hasPermission} from "@/utils/hasPermission"
	export default {
		name: "putawaystrategydetail",

		components: {
			putawaystrategydetailAddOrUpdate,
		},

		setup() {
			const {
				dataForm,
				mixinViewModuleOptions,
				getDataList,
				dataList,
				total,
				page,
				limit,
				dataListLoading,
				dataListSelectionChangeHandle,
				dataListSortChangeHandle,
				pageSizeChangeHandle,
				pageCurrentChangeHandle,
				addOrUpdateHandle,
				deleteHandle,
				exportHandle,
				addOrUpdateVisible,
				dataListSelections,
				addOrUpdate
			} = DataList();


			onMounted(() => {
				mixinViewModuleOptions.value.getDataListIsPage = true;
				mixinViewModuleOptions.value.getDataListURL = '/lswms/putawaystrategydetail/page';
				mixinViewModuleOptions.value.deleteURL = '/lswms/putawaystrategydetail';
				mixinViewModuleOptions.value.exportURL = '/lswms/putawaystrategydetail/export';
				mixinViewModuleOptions.value.deleteIsBatchKey = 'id';
				mixinViewModuleOptions.value.deleteIsBatch = true
				dataForm.value = {
					id: '',
					strategykey: ''
				}

				if (mixinViewModuleOptions.value.activatedIsNeed) {
					getDataList();
				}
				getZoneListFn();
				locTypeFn();
				locStatusFn();
				locCategoryFn();
				rowcollevorderFn();
				skusortFn()
				biggerorsmallerFn()
				putawaycodeFn();
			})

			const visible = ref(false);
			const init = () => {
				visible.value = true;
				nextTick(function() {
					console.log(dataForm.value.strategykey)
					if (dataForm.value.strategykey) {
						dataForm.value.id = '';
						getDataList()
					}

				})
			}


			//获取库位类型
			const locTypeList = ref("");
			const locTypeFn = () => {
				getCodeListByCode('loc_type').then((res) => {
					if (res.code !== 0) {
						return ElMessage.error(res.msg);
					}
					locTypeList.value = res.data;
				}).catch((err) => {});
			}
			//获取库位状态
			const locStatusList = ref("");
			const locStatusFn = () => {
				getCodeListByCode('loc_status').then((res) => {
					if (res.code !== 0) {
						return ElMessage.error(res.msg);
					}
					locStatusList.value = res.data;
				}).catch((err) => {});
			}
			//获取库位类别
			const locCategoryList = ref("");
			const locCategoryFn = () => {
				getCodeListByCode('loc_category').then((res) => {
					if (res.code !== 0) {
						return ElMessage.error(res.msg);
					}
					locCategoryList.value = res.data;
				}).catch((err) => {});
			}

			//获物料分类
			const skusortList = ref("");
			const skusortFn = () => {
				getCodeListByCode('SKUSORT').then((res) => {
					if (res.code !== 0) {
						return ElMessage.error(res.msg);
					}
					skusortList.value = res.data;
				}).catch((err) => {});
			}

			//获排列排顺序
			const rowcollevorderList = ref("");
			const rowcollevorderFn = () => {
				getCodeListByCode('xyzorder').then((res) => {
					if (res.code !== 0) {
						return ElMessage.error(res.msg);
					}
					rowcollevorderList.value = res.data;
				}).catch((err) => {});
			}

			//获变大或变小
			const biggerorsmallerList = ref("");
			const biggerorsmallerFn = () => {
				getCodeListByCode('biggerorsmaller').then((res) => {
					if (res.code !== 0) {
						return ElMessage.error(res.msg);
					}
					biggerorsmallerList.value = res.data;
				}).catch((err) => {});
			}

			//获变大或变小
			const putawaycodeList = ref("");
			const putawaycodeFn = () => {
				getCodeListByCode('putawaycode').then((res) => {
					if (res.code !== 0) {
						return ElMessage.error(res.msg);
					}
					putawaycodeList.value = res.data;
				}).catch((err) => {});
			}


			const zoneList = ref({});
			const getZoneListFn = () => {
				getzonelist().then((res) => {
					if (res.code !== 0) {
						return ElMessage.error(res.msg);
					}
					zoneList.value = res.data;
				}).catch((err) => {});
			}



			// 新增 / 修改
			const addOrUpdaputawaystrategydetailHandle = (id, strategykey) => {
				//
				addOrUpdateVisible.value = true;
				nextTick(function() {
					addOrUpdate.value.dataForm.id = id;
					addOrUpdate.value.dataForm.strategykey = strategykey;
					addOrUpdate.value.init();
				})
			}

			return {
				dataForm,
				mixinViewModuleOptions,
				getDataList,
				dataList,
				total,
				page,
				limit,
				dataListLoading,
				dataListSelectionChangeHandle,
				dataListSortChangeHandle,
				pageSizeChangeHandle,
				pageCurrentChangeHandle,
				addOrUpdateHandle,
				deleteHandle,
				exportHandle,
				addOrUpdateVisible,
				dataListSelections,
				addOrUpdate,
				init,
				visible,
				addOrUpdaputawaystrategydetailHandle,
				locTypeList,
				locStatusList,
				locCategoryList,
				zoneList,
				skusortList,
				rowcollevorderList,
				biggerorsmallerList,
				putawaycodeList
			}
		},
		methods:{
			hasPermission
		}
	}
</script>

<style scoped>

</style>
